package logo;

import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.RenderingHints;
import java.awt.image.BufferedImage;

import javax.swing.JPanel;

public class LogoPanel extends JPanel {

	private static final long serialVersionUID = 1L;
	Image _image;
	Graphics2D _big;
	Logo _parent;
	
	public Graphics2D getBufferedGraphics()
	{
		if (_big == null)
		{
			_image = new BufferedImage(_parent._sizex, _parent._sizey, BufferedImage.TYPE_INT_RGB);
			_big = ((BufferedImage)_image).createGraphics();
		}
		return _big;
	}
	
	public void clearPanel()
	{
		_big.setColor(getBackground());
		_big.fillRect(0, 0, _parent._sizex, _parent._sizey);
		repaint();
	}
	
	public LogoPanel(Logo l)
	{
		_parent = l;
		_image = null;
		_big = null;
	}

	@Override
	public void paint(Graphics g)
	{
		Graphics2D g2d = (Graphics2D) g;
		g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
		g2d.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
		g2d.drawImage(_image, 0, 0, null);
		_parent._turtle.setGraphics(g2d);
		_parent._turtle.paintTurtle();
	}
	
}
